home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: judgemi@ix.netcom.com(Michael Judge )
- Newsgroups: comp.lang.c++
- Subject: ODBC/OLE/Visual C++ problem. PLEASE
- Date: 5 Feb 1996 23:27:48 GMT
- Organization: Netcom
- Message-ID: <4f63pk$sjf@reader2.ix.netcom.com>
- NNTP-Posting-Host: bos-ma9-23.ix.netcom.com
- X-NETCOM-Date: Mon Feb 05 3:27:48 PM PST 1996
-
- This is for OLE/ODBC/Microsoft Visual C++ Gurus.
-
- environment: Windows 3.X, ODBC DLLs ver 2.1
-
- O.k. here is the problem then I will describe how to reproduce it.
- (takes 5 minutes to reproduce)
- When executing a SQL statement twice on a microsoft ODBC datasource, I
- recieve a GP fault in COMPOBJ.DLL. This ONLY happens when ODBC drivers
- version 2.1 have been installed. So any new machine, or old one with
- new software will reproduce this.
-
- If I replace OLE2DISP.DLL ver 2.1 with OLE2DISP.DLL ver 2.0 this
- problem doesnt occur. (of course there are other side affects
- that make this a poor solution.)
-
- here is the kicker! This only happens when I have a 'WHERE' clause in
- the statement. and ONLY in RELEASE!
-
- how to reproduce.
-
- 1: AppWizard new project.
- a. OLE options. (container)
- b. shut off all check boxes under options. (simplifies things)
- c. database support, include header files only
- d. classes: change your view class to a formview class.
- e. let it create all its files
- 2. AppStudio.
- a. Add a button to your formview
- b. class wizard: add a message map for bn_clicked
- c. choose edit code
- 3. CMyFormView::OnButton1() should look like this (also add derivation
- of CRecordset)
-
- class CMyRecordSet: public CRecordset
- {
- public:
- CMyRecordSet(CDatabase *t_ptr);
- virtual CString GetDefaultSQL(){return CString("");}
- virtual void DoFieldExchange(CFieldExchange* pFX){}
- };
- CMyRecordSet::CMyRecordSet(CDatabase *t_ptr)
- :CRecordset(t_ptr)
- {
- }
-
- void CMyFormView::OnButton1()
- {
- CDatabase t_pdatabase;
- t_pdatabase.Open(NULL);
- CMyRecordSet t_set(&t_pdatabase);
- t_set.Open();
- CString t_sqlstatement("SELECT TESTCOLUMN from TESTTABLE where
- TESTCOLUMN='EXAMPLE'");
- ::SQLExecDirect(t_set.m_hstmt,(UCHAR
- FAR*)t_sqlstatement.GetBuffer(0), SQL_NTS);
- t_set.Close();
- t_pdatabase.Close();
- }
-
- 4. change t_sqlstatement to be whatever makes sense to your database
- you are going after
- 5. build for release and execute.
- 6. click on button
- 7. choose a datasource that uses ODBCJT16.DLL (I have tried foxprow,
- access and paradox datasources)
- note: make sure your SQL makes sense
- 8. let it process call then click on button again.
-
- Thats it.
- Oh yes, after this happens, it wont blow up again until you leave
- windows and return.
- I have a VB test app that works fine with it.
- In debug it works
- replace OLE2DISP.DLL v2.1 with v2.0 it works
- if not an ole container it works
-
- I am almost in tears here please help!
-
- Email as well as post please.
- Email: judgemi@ix.netx.com
-
-